﻿using System;
using Microsoft.Extensions.DependencyInjection;
using SourceCodeIoc.Factory;
using SourceCodeIoc.Model;

namespace SourceCodeIoc
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //IServiceCollection services = new ServiceCollection();
            //ServiceProvider serviceProvider = services.BuildServiceProvider();

            #region ioc容器
            {
                //keyValuePairs.Remove("xx");
                // 1、创建IOC容器
                //抽象工厂模式
                AbstractIOCFactory defaultIOCFactory = new DefaultFactory();
                defaultIOCFactory.objectCreateStrategy = new ActivatorObjectCreateStrategy(); //策略模式
                // 开始范围
                Student student = (Student)defaultIOCFactory.GetObject(typeof(Student).FullName);
                student.Study();


                //// scope生命周期使用。
                //defaultIOCFactory.StartScope();

                //Student student1 = (Student)defaultIOCFactory.GetObject("RuanMou.ArchitectRelax.DesignMode1.IOC.Examples.Student");
                //Student student2 = (Student)defaultIOCFactory.GetObject("RuanMou.ArchitectRelax.DesignMode1.IOC.Examples.Student");
                //Student student3 = (Student)defaultIOCFactory.GetObject("RuanMou.ArchitectRelax.DesignMode1.IOC.Examples.Student");

                //defaultIOCFactory.StopScope();
            }
            #endregion
        }
    }
}
